perm filename GUIDE3.MEM[PRO,LOG] blob sn#603396 filedate 1981-10-28 generic text, type T, neo UTF8

                    A GUIDE TO VERSION 3 OF DEC-10 PROLOG
                    A GUIDE TO VERSION 3 OF DEC-10 PROLOG
                    A GUIDE TO VERSION 3 OF DEC-10 PROLOG
                    A GUIDE TO VERSION 3 OF DEC-10 PROLOG
                    A GUIDE TO VERSION 3 OF DEC-10 PROLOG


                Lawrence Byrd, Fernando Pereira, David Warren
                    Department of Artificial Intelligence
                           University of Edinburgh
                                  June 1980



1. SUMMARY
1. SUMMARY
1. SUMMARY
1. SUMMARY
1. SUMMARY

  The  new  features  introduced  by  this version of DEC-10 Prolog include an
"incore" compiler (incorporating "tail recursion optimisation"),  an  improved
set  of  program  development  aids, and new evaluable predicates, notably the
'setof' predicate.



2. INCOMPATIBLE CHANGES
2. INCOMPATIBLE CHANGES
2. INCOMPATIBLE CHANGES
2. INCOMPATIBLE CHANGES
2. INCOMPATIBLE CHANGES

  The following changes (with respect to the version described in  the  User's
Guide) may affect existing programs:

   1. New evaluable predicates have been introduced (see later sections).

   2. The  original  "internal  database"  has  been superseded by a more
      sophisticated version providing recording under a key.

   3. The evaluable predicate 'not(P)' has been renamed '\+(P)'.

   4. The  evaluable  predicate  'retractall(P)'  has  been  replaced  by
      'abolish(F,N)'.

   5. The precedence of the operator 'mode' has been increased, operators
      ':='  and  '+:=' have been dropped, and new standard operators have
      been added (see later).

   6. The end of file marker returned by 'read'  is  now  different  (see
      below).

   7. The  character  '%'  is  no longer available as a solo character in
      Prolog text.

                                               carriage-return  line-feed
                                               carriage-return  line-feed
                                               carriage-return  line-feed
                                               carriage-return  line-feed
   8. In character input/output, the sequence  carriage-return  line-feed
                           newline           
                           newline           
                           newline           
                           newline           
      is translated into a newline character.
                                      2

3. THE INCORE COMPILER
3. THE INCORE COMPILER
3. THE INCORE COMPILER
3. THE INCORE COMPILER
3. THE INCORE COMPILER

  It is now possible to compile a Prolog program contained in one or more text
files  directly  into  memory,  ready  for immediate execution.  Outwardly the
effect is very similar to the use of 'reconsult' to read-in a program  to  the
interpreter.    Compilation  has  the advantage that the program runs 10 or 20
times faster, requires much less working storage, and normally occupies rather
less space than interpreted code.  In addition, compiled clauses  are  indexed
(see  below).    However,  against  this,  compilation itself is several times
slower than "consulting" and most of the debugging aids, such as tracing,  are
not applicable to compiled code.


3.1. Calling the Compiler
3.1. Calling the Compiler
3.1. Calling the Compiler
3.1. Calling the Compiler
3.1. Calling the Compiler

  To compile a program, use the evaluable predicate:

            Files 
            Files 
            Files 
            Files 
    compile(Files)

      Files                                                                   
      Files                                                                   
      Files                                                                   
      Files                                                                   
where Files is either the name of a file (including the ersatz file 'user') or
a  list  of  file  names.    The  procedures  contained in these files will be
compiled.  For example:

    ?- compile([dbase,'extras.pl',user]).

  If clauses for some predicate appear in more than one file,  the  later  set
will  effectively  overwrite  the earlier set, ie. 'compile' behaves much like
'reconsult'.  The division of the program into separate files does  not  imply
any  module  structure  -  any  compiled procedure can call any other.  Again,
compare 'reconsult' and contrast the stand-alone compiler.

  In general, compiled and interpreted predicates are treated as  being  quite
separate,  even  if  they have the same name.  Thus compiled procedures cannot
automatically be called from interpreted code, nor vice versa.    However,  if
compiled  code  contains a call to a predicate for which no compiled procedure
has been supplied, the corresponding interpreted  version  (if  any)  will  be
called.    Also,  as usual, all interpreted procedures can be accessed through
the evaluable predicate 'call(←)'.


3.2. Public Declarations
3.2. Public Declarations
3.2. Public Declarations
3.2. Public Declarations
3.2. Public Declarations

  To make a compiled procedure accessible  from  interpreted  code  (including
directives)  it  is necessary to declare it to be "public", using the compiler
directive:

             Predicates 
             Predicates 
             Predicates 
             Predicates 
    :-public Predicates.

      Predicates                                                   Name Arity 
      Predicates                                                   Name Arity 
      Predicates                                                   Name Arity 
      Predicates                                                   Name Arity 
where Predicates is either a predicate specification of the  form  Name/Arity,
or a conjunction of such specifications. For example:

    :-public concatenate/3, member/2, ordered/1, go/0.
                                      3

Public  declarations  may  appear  anywhere within a compiled file.  It is not
necessary for the public declaration to precede the  corresponding  procedure,
nor even for them to be in the same file.

  For  public  predicates,  the  compiled procedure overwrites any interpreted
version  (cf.  'reconsult').    Similarly,  a  subsequent  'reconsult'  of  an
interpreted version will overwrite the compiled version.

  When  a  compiled version of a public procedure is in force, the interpreted
procedure is actually replaced by a clause:

    P           P  
    P           P  
    P           P  
    P           P  
    P :- incore(P).

      P                                                                       
      P                                                                       
      P                                                                       
      P                                                                       
where P is the most general goal for that predicate, and where 'incore(←)'  is
a  standard  evaluable  predicate,  analogous  to 'call(←)', through which are
accessible all the compiled procedures for public predicates.

  Note that one can therefore effectively extend or modify a public  procedure
using  'consult',  'assert's  etc.,  but these changes will only be visible to
interpreted code.


3.3. Mode Declarations
3.3. Mode Declarations
3.3. Mode Declarations
3.3. Mode Declarations
3.3. Mode Declarations

  As with the stand-alone compiler, mode  declarations  may  be  supplied  for
compiled  predicates. (This enables the compiler to generate more compact code
making better use of runtime storage).  The syntax is slightly extended:

           Modes 
           Modes 
           Modes 
           Modes 
    :-mode Modes.

      Modes                                                                   
      Modes                                                                   
      Modes                                                                   
      Modes                                                                   
where Modes is either the mode specification for  a  single  predicate,  or  a
conjunction of such specifications, eg.

    :-mode concatenate(+,?,-), member(?,+), ordered(+).


3.4. Indexing
3.4. Indexing
3.4. Indexing
3.4. Indexing
3.4. Indexing

  As  with  the stand-alone compiler (and in contrast to the interpreter), the
clauses of a compiled procedure are indexed according to the principal functor
of the first argument in the head.  This means  that  the  subset  of  clauses
which  match  a  given  goal,  as  far  as  the  first  step of unification is
concerned, is found very quickly, in practically constant time (ie. in a  time
independent  of  the  number  of  clauses in the procedure).  This can be very
important where there is a large number of clauses in a procedure.    Indexing
also  improves  the  Prolog system's ability to detect determinacy - important
for conserving working storage.
                                      4

3.5. Tail Recursion Optimisation
3.5. Tail Recursion Optimisation
3.5. Tail Recursion Optimisation
3.5. Tail Recursion Optimisation
3.5. Tail Recursion Optimisation

  The  incore compiler incorporates a "tail recursion optimisation" to improve
the speed and space efficiency of determinate procedures.

  When execution  reaches  the  last  goal  in  a  clause  belonging  to  some
procedure,  and  provided  there  are  no  remaining  backtrack  points in the
execution so far of that procedure,  all  of  the  procedure's  local  working
             immediately                                                      
             immediately                                                      
             immediately                                                      
             immediately                                                      
storage  is  immediately  reclaimed,  and any structures it has created become
eligible for garbage collection.  This means that programs can now recurse  to
arbitrary depths without necessarily exceeding core limits.  For example:

    cycle(State) :- transform(State,State1), cycle(State1).

where   'transform'   is   a  determinate  procedure  can  continue  executing
indefinitely, provided each individual structure, State,  is  not  too  large.
The  procedure  'cycle'  is  equivalent to an iterative loop in a conventional
language.

  To take advantage of the tail recursion optimisation one  must  ensure  that
the  Prolog  system  can  recognise  that  the procedure is determinate at the
appropriate point.  In general  this  involves  reliance  on  DEC-10  Prolog's
indexing and/or use of cut.


3.6. Practical Limitations
3.6. Practical Limitations
3.6. Practical Limitations
3.6. Practical Limitations
3.6. Practical Limitations

  At present, the space occupied by superseded compiled code is not reclaimed.

  Making a predicate public leads to the generation of a significant amount of
extra  code.    Moreover,  at  present,  this  code is re-generated every time
'compile' is  called,  (and  the  space  occupied  by  the  old  code  is  not
reclaimed).  Therefore it is important to include all the files to be compiled
in a single call to 'compile', if at all possible.

  You  may  notice  that  there  is a slight pause on starting and finishing a
compilation.  This is because the compiler  resides  in  a  separate  overlay,
which has to be swapped in and out.



4. PROGRAM DEVELOPMENT AIDS
4. PROGRAM DEVELOPMENT AIDS
4. PROGRAM DEVELOPMENT AIDS
4. PROGRAM DEVELOPMENT AIDS
4. PROGRAM DEVELOPMENT AIDS

  For  details of the new debugging facilities see the separate paper "DEBUG".
Notice, however, that the evaluable predicates concerned  with  debugging  are
also described below in section 7.8.
                                      5

5. OTHER NEW FEATURES
5. OTHER NEW FEATURES
5. OTHER NEW FEATURES
5. OTHER NEW FEATURES
5. OTHER NEW FEATURES


5.1. Initialisation File
5.1. Initialisation File
5.1. Initialisation File
5.1. Initialisation File
5.1. Initialisation File

  When  Prolog  starts,  it looks for file PROLOG.INI in the user's directory,
and consults it if found.


5.2. Terminal prompts
5.2. Terminal prompts
5.2. Terminal prompts
5.2. Terminal prompts
5.2. Terminal prompts

  When reading input from the terminal, the system now uses different  prompts
to  distinguish  different  levels  of  the system.  The interpreter top level
outputs '| ?- '  before  reading  the  next  directive,  and  the  prompt  (on
following  lines)  becomes '|    '.  When (re)consulting from the terminal the
prompt becomes '| '.  During program execution (ie for user input), the prompt
will normally be '|: '.  However, this last case can be changed by  the  user,
during execution, with the evaluable predicate 'prompt' (see below).

  When  the  system  asks  for a single character response, it will never read
beyond the end of the line; therefore there are no  continuation  prompts  for
these  cases.  This type of response occurs in three places:  at the top level
                                                          carriage-return     
                                                          carriage-return     
                                                          carriage-return     
                                                          carriage-return     
after  the  values  of  variables  have  been  output  (";carriage-return"  to
             carriage-return                                                  
             carriage-return                                                  
             carriage-return                                                  
             carriage-return                                                  
backtrack,  "carriage-return" to finish); after tracing messages (as described
earlier); and in reply to  the  interrupt  handler.    These  lines  are  also
completely  flushed up to the end of line.  This habit is recommended to users
who perform character I/O from the terminal, otherwise  left  over  characters
(especially end of lines) are apt to be read by the debugging package.


5.3. End of Line Comments
5.3. End of Line Comments
5.3. End of Line Comments
5.3. End of Line Comments
5.3. End of Line Comments

  All  the  term input predicates ('read', 'consult', etc.) treat as a comment
any text between the character '%' and the end of the line, except if the  '%'
appears inside a quoted atom, a string, or immediately before a parenthesis.


5.4. Handling of Line Terminators
5.4. Handling of Line Terminators
5.4. Handling of Line Terminators
5.4. Handling of Line Terminators
5.4. Handling of Line Terminators

                                   carriage-return line-feed                  
                                   carriage-return line-feed                  
                                   carriage-return line-feed                  
                                   carriage-return line-feed                  
  In character input, the sequence carriage-return line-feed is read in as the
                   newline                                                    
                   newline                                                    
                   newline                                                    
                   newline                                                    
single  character  newline,  ASCII  code 31. This is reversed on output, where
         newline           carriage-return line-feed                          
         newline           carriage-return line-feed                          
         newline           carriage-return line-feed                          
         newline           carriage-return line-feed                          
'put'ing newline inserts a carriage-return line-feed sequence  in  the  output
stream.


5.5. End of File Marker
5.5. End of File Marker
5.5. End of File Marker
5.5. End of File Marker
5.5. End of File Marker

  The  end  of  file  marker returned by 'read' is now the atom 'end←of←file',
instead of the term ':-end', which was returned in earlier versions.
                                      6

6. NEW OPERATORS
6. NEW OPERATORS
6. NEW OPERATORS
6. NEW OPERATORS
6. NEW OPERATORS

  The following are new standard operators:

    :-op(1150,fx,[mode,public]).
    :-op(900,fy,[\+,spy,nospy]).
    :-op(700,xfx,[@<,@>,@=<,@>=]).
    :-op(200,xfy,[↑]).

and  some  of  the  old ones have been dropped.  The complete list of standard
operators is now:

    :-op( 1200, xfx, [ :-, --> ]).
    :-op( 1200,  fx, [ :-, ?- ]).
    :-op( 1150,  fx, [ mode, public ]).
    :-op( 1100, xfy, [ ; ]).
    :-op( 1050, xfy, [ -> ]).
    :-op( 1000, xfy, [ ',' ]).
    :-op(  900,  fy, [ \+, spy, nospy ]).
    :-op(  700, xfx, [ =, is, =.., ==, \==, @<, @>, @=<, @>=,
                                   =:=, =\=, <, >, =<, >= ]).
    :-op(  500, yfx, [ +, -, /\, \/ ]).
    :-op(  500,  fx, [ +, - ]).
    :-op(  400, yfx, [ *, /, <<, >> ]).
    :-op(  300, xfx, [ mod ]).
    :-op(  200, xfy, [ ↑ ]).



7. NEW EVALUABLE PREDICATES
7. NEW EVALUABLE PREDICATES
7. NEW EVALUABLE PREDICATES
7. NEW EVALUABLE PREDICATES
7. NEW EVALUABLE PREDICATES


7.1. Compiled Program
7.1. Compiled Program
7.1. Compiled Program
7.1. Compiled Program
7.1. Compiled Program


        Files 
        Files 
        Files 
        Files 
compile(Files)

                                                     Files                    
                                                     Files                    
                                                     Files                    
                                                     Files                    
     Compiles the file or list of files specified by Files. (See section above
     on the incore compiler).

       Goal 
       Goal 
       Goal 
       Goal 
incore(Goal)

              Goal                                                            
              Goal                                                            
              Goal                                                            
              Goal                                                            
     The term Goal is interpreted as a  call  to  a  current  public  compiled
     procedure.

        Name Arity 
        Name Arity 
        Name Arity 
        Name Arity 
abolish(Name,Arity)

     Effectively removes the procedure, either interpreted or public compiled,
                                         Name       Arity                     
                                         Name       Arity                     
                                         Name       Arity                     
                                         Name       Arity                     
     for  the  predicate  specified  by  Name  and  Arity).  cf. the evaluable
     predicate 'retractall(←)', which is no longer available.

       Name Arity 
       Name Arity 
       Name Arity 
       Name Arity 
revive(Name,Arity)
                                      7


                                        Name      Arity                       
                                        Name      Arity                       
                                        Name      Arity                       
                                        Name      Arity                       
     If  the  predicate  specified  by  Name  and Arity is public, the current
     interpreted procedure (if any) for that predicate is replaced by the most
     recent compiled version.  Otherwise the call has no effect.


7.2. Interpreted Program etc.
7.2. Interpreted Program etc.
7.2. Interpreted Program etc.
7.2. Interpreted Program etc.
7.2. Interpreted Program etc.


 File Files 
 File Files 
 File Files 
 File Files 
[File|Files]

     This shorthand way of consulting or reconsulting a list of files now  has
     full  status  as  an evaluable predicate, instead of being just a special
     command.

        Predicate 
        Predicate 
        Predicate 
        Predicate 
listing(Predicate)

                                                                Predicate     
                                                                Predicate     
                                                                Predicate     
                                                                Predicate     
     This evaluable predicate has been extended. The  argument  Predicate  may
                                                    Name Arity                
                                                    Name Arity                
                                                    Name Arity                
                                                    Name Arity                
     now  be  a predicate specification of the form Name/Arity.  The effect is
     to produce a listing  of  the  interpreted  clauses  for  the  particular
                               Predicate                                      
                               Predicate                                      
                               Predicate                                      
                               Predicate                                      
     predicate  specified.  If Predicate is just an atom, then the interpreted
     procedures for all predicates of that name  are  listed,  as  before.  In
                                       Predicate                              
                                       Predicate                              
                                       Predicate                              
                                       Predicate                              
     addition,  it  is  possible  for  Predicate  to  be  a  list of predicate
     specifications of either type, eg.

         :-listing([concatenate/3, reverse, go/0]).

       Head Body Ref 
       Head Body Ref 
       Head Body Ref 
       Head Body Ref 
clause(Head,Body,Ref)

                           Head Body         Ref                              
                           Head Body         Ref                              
                           Head Body         Ref                              
                           Head Body         Ref                              
     Equivalent to 'clause(Head,Body)' where Ref is an implementation  defined
                                                              Ref             
                                                              Ref             
                                                              Ref             
                                                              Ref             
     term  which uniquely identifies the clause concerned. If Ref is not given
                              Head                                            
                              Head                                            
                              Head                                            
                              Head                                            
     at the time of the call, Head must  be  instantiated  to  a  non-variable
     term.  Thus this predicate can have two different modes of use, depending
     on whether the identifier of the clause  is  known  or  unknown.  Compare
     'instance(←,←)'.

       Clause Ref 
       Clause Ref 
       Clause Ref 
       Clause Ref 
assert(Clause,Ref)

                             Clause          Ref                              
                             Clause          Ref                              
                             Clause          Ref                              
                             Clause          Ref                              
     Equivalent  to  'assert(Clause)'  where Ref is the implementation defined
     identifier of the clause asserted.

        Clause Ref 
        Clause Ref 
        Clause Ref 
        Clause Ref 
asserta(Clause,Ref)

                            Clause         Ref                                
                            Clause         Ref                                
                            Clause         Ref                                
                            Clause         Ref                                
     Equivalent to 'asserta(Clause)' where Ref is the  implementation  defined
     identifier of the clause asserted.

        Clause Ref 
        Clause Ref 
        Clause Ref 
        Clause Ref 
assertz(Clause,Ref)

                              Clause         Ref                              
                              Clause         Ref                              
                              Clause         Ref                              
                              Clause         Ref                              
     Equivalent  to  'assertz(Clause)' where Ref is the implementation defined
     identifier of the clause asserted.
                                      8

7.3. Internal Database
7.3. Internal Database
7.3. Internal Database
7.3. Internal Database
7.3. Internal Database


         Key Term Ref 
         Key Term Ref 
         Key Term Ref 
         Key Term Ref 
recorded(Key,Term,Ref)

                                                                          Key 
                                                                          Key 
                                                                          Key 
                                                                          Key 
     The  internal  database is searched for terms recorded under the key Key.
                                               Term                           
                                               Term                           
                                               Term                           
                                               Term                           
     These terms are successively unified with Term in the order they occur in
                                     Ref                                      
                                     Ref                                      
                                     Ref                                      
                                     Ref                                      
     the database. At the same time, Ref is  unified  with  an  implementation
     defined  term  uniquely  identifying  the recorded item.  The key must be
     given, and may be an atom, integer or complex term.  In  the  case  of  a
     complex term, only the principal functor is significant.

        Key Term Ref 
        Key Term Ref 
        Key Term Ref 
        Key Term Ref 
recorda(Key,Term,Ref)

               Term                                                           
               Term                                                           
               Term                                                           
               Term                                                           
     The  term Term is recorded in the internal database as the first item for
             Key        Ref                                                   
             Key        Ref                                                   
             Key        Ref                                                   
             Key        Ref                                                   
     the key Key, where Ref is its implementation defined identifier. The  key
     must be given, and only its principal functor is significant.

        Key Term Ref 
        Key Term Ref 
        Key Term Ref 
        Key Term Ref 
recordz(Key,Term,Ref)

                Term                                                          
                Term                                                          
                Term                                                          
                Term                                                          
     The  term  Term is recorded in the internal database as the last item for
             Key        Ref                                                   
             Key        Ref                                                   
             Key        Ref                                                   
             Key        Ref                                                   
     the key Key, where Ref is its implementation defined identifier. The  key
     must be given, and only its principal functor is significant.

      Ref 
      Ref 
      Ref 
      Ref 
erase(Ref)

                          or                                                  
                          or                                                  
                          or                                                  
                          or                                                  
     The  recorded  item  or  interpreted  clause whose implementation defined
                   Ref                                                        
                   Ref                                                        
                   Ref                                                        
                   Ref                                                        
     identifier is Ref is effectively erased from  the  internal  database  or
     interpreted program.

         Ref Term 
         Ref Term 
         Ref Term 
         Ref Term 
instance(Ref,Term)

     A  (most  general)  instance  of  the  recorded term whose implementation
                           Ref                 Term 
                           Ref                 Term 
                           Ref                 Term 
                           Ref                 Term 
     defined identifier is Ref is unified with Term.


7.4. Meta-Logical
7.4. Meta-Logical
7.4. Meta-Logical
7.4. Meta-Logical
7.4. Meta-Logical


             Atom 
             Atom 
             Atom 
             Atom 
current←atom(Atom)

     Generates (through backtracking) all currently known atoms,  and  returns
                 Atom 
                 Atom 
                 Atom 
                 Atom 
     each one as Atom.

                Name Functor 
                Name Functor 
                Name Functor 
                Name Functor 
current←functor(Name,Functor)

     Generates  (through  backtracking)  all currently known functors, and for
                                                            Name       Functor
                                                            Name       Functor
                                                            Name       Functor
                                                            Name       Functor
     each one returns its name and most  general  term  as  Name  and  Functor
                        Name                                                  
                        Name                                                  
                        Name                                                  
                        Name                                                  
     respectively.  If  Name  is  given,  only  functors  with  that  name are
     generated.

                  Name Functor 
                  Name Functor 
                  Name Functor 
                  Name Functor 
current←predicate(Name,Functor)
                                      9


     Similar   to   'current←functor',   but   it   only   generates  functors
     corresponding  to  predicates  for  which  there  currently   exists   an
     interpreted procedure.

      X P S 
      X P S 
      X P S 
      X P S 
setof(X,P,S)

                   S                                X           P             
                   S                                X           P             
                   S                                X           P             
                   S                                X           P             
     Read this as "S is the set of all instances of X such that P is provable,
                                             P                                
                                             P                                
                                             P                                
                                             P                                
     where that set is non-empty".  The term P specifies a goal or goals as in
           P                                                                  
           P                                                                  
           P                                                                  
           P                                                                  
     'call(P)'.    A  set  of  terms  is represented as a list of those terms,
     without duplicates, in the standard order for terms  (see  Comparison  of
                                                                  X           
                                                                  X           
                                                                  X           
                                                                  X           
     Terms,  below).    Note that variables appearing in the term X should not
                                                               P              
                                                               P              
                                                               P              
                                                               P              
     appear anywhere else in the clause except within the term P.   Obviously,
     the  set  to  be enumerated should be finite, and should be enumerable by
     Prolog in finite  time.  Note  that  it  is  possible  for  the  provable
                                                                   S          
                                                                   S          
                                                                   S          
                                                                   S          
     instances  to  contain  variables,  but in this case the list S will only
     provide an imperfect representation of what is  in  reality  an  infinite
     set.

     Note  that  a call to this evaluable predicate can potentially backtrack,
                                                         S                    
                                                         S                    
                                                         S                    
                                                         S                    
     generating alternative values for the non-empty set S,  corresponding  to
                                                       P                      
                                                       P                      
                                                       P                      
                                                       P                      
     different instantiations of the free variables of P.  (It is to cater for
                              S                                               
                              S                                               
                              S                                               
                              S                                               
     such  usage that the set S is constrained to be non-empty).  For example,
     the call:

         ?- setof(X, X likes Y, S).

     might produce:

         Y = beer,   X = [dick, harry, tom]
         Y = cider,  X = [bill, jan, tom ]

     The call:

         ?- setof((Y,S), setof(X, X likes Y, S), SS).

     would then produce:

         SS = [ (beer,[dick,harry,tom]), (cider,[bill,jan,tom]) ]

                            P                                                 
                            P                                                 
                            P                                                 
                            P                                                 
     Variables occurring in P  will  not  be  treated  as  free  if  they  are
                               P                                              
                               P                                              
                               P                                              
                               P                                              
     explicitly  bound  within P by an existential quantifier.  An existential
     quantification is written:

         Y Q
         Y Q
         Y Q
         Y Q
         Y↑Q

                             Y           Q                 Y                  
                             Y           Q                 Y                  
                             Y           Q                 Y                  
                             Y           Q                 Y                  
     meaning "there exists a Y such that Q is true", where Y  is  some  Prolog
     variable.  For example:

         ?- setof(X, Y↑(X likes Y), S).

     would produce the single result:
                                      10

         X = [bill, dick, harry, jan, tom]

     in contrast to the earlier example.

      X P Bag 
      X P Bag 
      X P Bag 
      X P Bag 
bagof(X,P,Bag)

                                              X P S                           
                                              X P S                           
                                              X P S                           
                                              X P S                           
     This  is  exactly  the  same  as  'setof(X,P,S)' except that the list (or
     alternative  lists)  returned  will  not  be  ordered,  and  may  contain
     duplicates.    The effect of this relaxation is to save considerable time
     and space in execution.

X P
X P
X P
X P
X↑P

                                                                 X           P
                                                                 X           P
                                                                 X           P
                                                                 X           P
     The interpreter recognises this as meaning "there exists an X such that P
                                                    P                         
                                                    P                         
                                                    P                         
                                                    P                         
     is true", and treats it as equivalent to 'call(P)'.    The  use  of  this
     explicit   existential   quantifier   outside  the  'setof'  and  'bagof'
     constructs is  superfluous,  and  therefore  is  not  recognised  by  the
     compiler.


7.5. Comparison of Terms
7.5. Comparison of Terms
7.5. Comparison of Terms
7.5. Comparison of Terms
7.5. Comparison of Terms

  The  evaluable  predicates  which  follow make reference to a standard total
ordering of terms, which is as follows:

   - variables, in a standard order (roughly, oldest first);

   - integers, from - "infinity" to + "infinity";

   - atoms, in alphabetical (ie. ASCII) order;

   - complex terms, ordered first by arity, then by the name of principal
     functor, then by the arguments (in left-to-right order).

For example, here is a list of terms in the standard order:

    [ X, Y, -9, 1, fie, foe, fum, X = X, X = Y, fie(0,2), fie(1,1) ]


        Op T1 T2 
        Op T1 T2 
        Op T1 T2 
        Op T1 T2 
compare(Op,T1,T2)

                                   T1     T2    Op                            
                                   T1     T2    Op                            
                                   T1     T2    Op                            
                                   T1     T2    Op                            
     The result of comparing terms T1 and T2 is Op, where the possible  values
         Op     
         Op     
         Op     
         Op     
     for Op are:

                   T1                 T2 
                   T1                 T2 
                   T1                 T2 
                   T1                 T2 
          '='   if T1 is identical to T2,
                   T1           T2                       
                   T1           T2                       
                   T1           T2                       
                   T1           T2                       
          '<'   if T1 is before T2 in the standard order,
                   T1          T2                       
                   T1          T2                       
                   T1          T2                       
                   T1          T2                       
          '>'   if T1 is after T2 in the standard order.

     Thus 'compare(=,T1,T2)' is equivalent to 'T1 == T2'.

T1    T2
T1    T2
T1    T2
T1    T2
T1 @< T2

                                      11

          T1                T2                       
          T1                T2                       
          T1                T2                       
          T1                T2                       
     Term T1 is before term T2 in the standard order.

T1    T2
T1    T2
T1    T2
T1    T2
T1 @> T2

          T1               T2                       
          T1               T2                       
          T1               T2                       
          T1               T2                       
     Term T1 is after term T2 in the standard order.

T1     T2
T1     T2
T1     T2
T1     T2
T1 @=< T2

          T1                   T2                       
          T1                   T2                       
          T1                   T2                       
          T1                   T2                       
     Term T1 is not after term T2 in the standard order.

T1     T2
T1     T2
T1     T2
T1     T2
T1 @>= T2

          T1                    T2                       
          T1                    T2                       
          T1                    T2                       
          T1                    T2                       
     Term T1 is not before term T2 in the standard order.

     L1 L2 
     L1 L2 
     L1 L2 
     L1 L2 
sort(L1,L2)

                                L1                                            
                                L1                                            
                                L1                                            
                                L1                                            
     The  elements  of the list L1 are sorted into the standard order, and any
                                                                   L2         
                                                                   L2         
                                                                   L2         
                                                                   L2         
     identical (ie. '==') elements are merged, yielding the  list  L2.    (The
                                              N     N       N                 
                                              N     N       N                 
                                              N     N       N                 
                                              N     N       N                 
     time  taken to do this is at worst order N log N where N is the length of
     L1  
     L1  
     L1  
     L1  
     L1).

        L1 L2 
        L1 L2 
        L1 L2 
        L1 L2 
keysort(L1,L2)

              L1                                   Key Value                  
              L1                                   Key Value                  
              L1                                   Key Value                  
              L1                                   Key Value                  
     The list L1 must consist of items of the form Key-Value.  These items are
                                                 Key                    L2    
                                                 Key                    L2    
                                                 Key                    L2    
                                                 Key                    L2    
     sorted into order according to the value of Key, yielding the list L2. No
                                                                       N     N
                                                                       N     N
                                                                       N     N
                                                                       N     N
     merging takes place. (The time taken to do this is at worst order N log N
           N                  L1  
           N                  L1  
           N                  L1  
           N                  L1  
     where N is the length of L1).


7.6. Input-Output
7.6. Input-Output
7.6. Input-Output
7.6. Input-Output
7.6. Input-Output


       Term 
       Term 
       Term 
       Term 
writeq(Term)

                       Term                                                   
                       Term                                                   
                       Term                                                   
                       Term                                                   
     Similar to 'write(Term)', but the names of atoms and functors are  quoted
     where necessary to make the result acceptable as input to 'read'.

      Term 
      Term 
      Term 
      Term 
print(Term)

            Term                                 Term                         
            Term                                 Term                         
            Term                                 Term                         
            Term                                 Term                         
     Print  Term  onto  the  current output.  If Term is a variable then it is
                           Term        Term                                   
                           Term        Term                                   
                           Term        Term                                   
                           Term        Term                                   
     written, using 'write(Term)'.  If Term is non-variable  then  a  call  is
                                                     Term                     
                                                     Term                     
                                                     Term                     
                                                     Term                     
     made  to  the  user  defined procedure 'portray(Term)'.  Should 'portray'
                                        Term                                  
                                        Term                                  
                                        Term                                  
                                        Term                                  
     fail (or be undefined) then 'write(Term)' will be  called,  otherwise  it
                              Term                                            
                              Term                                            
                              Term                                            
                              Term                                            
     will  be  assumed  that  Term  has  been output.  'print' thus provides a
     handle for user defined pretty printing.  In  particular,  the  debugging
     package  'print's  the goals in the tracing messages, and the interpreter
     top level 'print's the final values of variables.
                                      12

7.7. Environmental
7.7. Environmental
7.7. Environmental
7.7. Environmental
7.7. Environmental


       Old New 
       Old New 
       Old New 
       Old New 
prompt(Old,New)

     The  sequence  of  characters (prompt) which indicates that the system is
                                                                      Old     
                                                                      Old     
                                                                      Old     
                                                                      Old     
     waiting for user input is represented as an atom, and matched to Old; the
                   New                                                  
                   New                                                  
                   New                                                  
                   New                                                  
     atom bound to New specifies the new prompt. In particular, the goal

         prompt(X,X)

     matches the current prompt to X, without changing it.

           Precedence Type Op 
           Precedence Type Op 
           Precedence Type Op 
           Precedence Type Op 
current←op(Precedence,Type,Op)

              Op                                         Type                 
              Op                                         Type                 
              Op                                         Type                 
              Op                                         Type                 
     The atom Op  is  currently  an  operator  of  type  Type  and  precedence
     Precedence            Op                                                 
     Precedence            Op                                                 
     Precedence            Op                                                 
     Precedence            Op                                                 
     Precedence.  Neither  Op  nor the other arguments need be instantiated at
     the time of the call; ie. this predicate can be used to generate as  well
     as to test.


7.8. Debugging
7.8. Debugging
7.8. Debugging
7.8. Debugging
7.8. Debugging


debug

     Debug mode is switched on. Information will now be retained for debugging
     purposes and executions will require more space.

nodebug

     Debug  mode  is  switched  off.  Information  is  no  longer retained for
     debugging.

trace

     Debug mode is switched on, and an immediate CREEP decision  is  made,  so
     that  tracing  will  start  with the very next port through which control
     passes.  Since this is a once-off decision, a call to trace is  necessary
     whenever  tracing is required right from the start of an execution.  (The
     assumed decision is otherwise LEAP).

      Mode 
      Mode 
      Mode 
      Mode 
leash(Mode)

                        Mode                                                  
                        Mode                                                  
                        Mode                                                  
                        Mode                                                  
     Leashing is set to Mode.   This  will  affect  whether  or  not  you  are
                                                   Mode                       
                                                   Mode                       
                                                   Mode                       
                                                   Mode                       
     prompted  after  certain  tracing  messages.  Mode  can  be  one  of  the
     following:


full  - prompt on call, exit, redo and fail
tight - prompt on call, redo and fail
half  - prompt on call and redo
                                      13

loose - prompt on call
off   - never prompt


         Mode                                                                 
         Mode                                                                 
         Mode                                                                 
         Mode                                                                 
     or  Mode  can be an integer between 0 and 15 which will set any arbitrary
     combination not covered above.  (Treat the integer  as  a  binary  number
       CERF        C  E  R     F                                              
       CERF        C  E  R     F                                              
       CERF        C  E  R     F                                              
       CERF        C  E  R     F                                              
     2'CERF, where C, E, R and F give the yes/no (1/0) decisions for the call,
     exit,  redo  and fail ports respectively).  When a port is unleashed, the
     tracing message will still be output and then an automatic CREEP decision
     is made.  Note that the ports  of  spy-points  are  always  leashed  (and
     cannot be unleashed).

    Spec
    Spec
    Spec
    Spec
spy Spec

                                                                    Spec      
                                                                    Spec      
                                                                    Spec      
                                                                    Spec      
     Spy-points  will  be  placed  on  all  the procedures given by Spec.  All
     control flow through the ports of these  procedures  will  henceforth  be
     traced.    If debug mode was previously off, then it will be switched on.
     Spec                                                       Name/Arity    
     Spec                                                       Name/Arity    
     Spec                                                       Name/Arity    
     Spec                                                       Name/Arity    
     Spec can either be a predicate specification of the  form  Name/Arity  or
     Name                                                Name                 
     Name                                                Name                 
     Name                                                Name                 
     Name                                                Name                 
     Name,  or  a list of such specifications.  When the Name is given without
         Arity                                                                
         Arity                                                                
         Arity                                                                
         Arity                                                                
     the Arity this refers to all predicates of that name which currently have
     definitions.  If there are none, then nothing will be done.    Spy-points
     can  be  placed on particular undefined procedures only by using the full
           Name/Arity 
           Name/Arity 
           Name/Arity 
           Name/Arity 
     form, Name/Arity.

      Spec
      Spec
      Spec
      Spec
nospy Spec

                                                                Spec          
                                                                Spec          
                                                                Spec          
                                                                Spec          
     Spy-points are removed from all the procedures  given  by  Spec  (as  for
     'spy').

debugging

     Outputs information concerning the status of the debugging package.  This
     will  show: whether debug mode is on, and if it is - what spy-points have
     been set and what mode of leashing is in force.


7.9. Pre-Processing
7.9. Pre-Processing
7.9. Pre-Processing
7.9. Pre-Processing
7.9. Pre-Processing


            T1 T2 
            T1 T2 
            T1 T2 
            T1 T2 
expand←term(T1,T2)

     When program is read in, some of the terms read  are  transformed  before
                                   T1                                    T2   
                                   T1                                    T2   
                                   T1                                    T2   
                                   T1                                    T2   
     being  stored  as clauses. If T1 is a term that can be transformed, T2 is
                            T2         T1                                     
                            T2         T1                                     
                            T2         T1                                     
                            T2         T1                                     
     the result.  Otherwise T2 is just T1 unchanged.  The only  transformation
     currently available translates grammar rules into clauses.


7.10. Grammars
7.10. Grammars
7.10. Grammars
7.10. Grammars
7.10. Grammars


       P L 
       P L 
       P L 
       P L 
phrase(P,L)

                                      14

                L                          P                                  
                L                          P                                  
                L                          P                                  
                L                          P                                  
     The  list  L  is  a  phrase  of  type P (according to the current grammar
                   P                                                          
                   P                                                          
                   P                                                          
                   P                                                          
     rules), where P is either a non-terminal or more generally a grammar rule
           P                      
           P                      
           P                      
           P                      
     body. P must be non-variable.



8. GLOSSARY OF CURRENT EVALUABLE PREDICATES
8. GLOSSARY OF CURRENT EVALUABLE PREDICATES
8. GLOSSARY OF CURRENT EVALUABLE PREDICATES
8. GLOSSARY OF CURRENT EVALUABLE PREDICATES
8. GLOSSARY OF CURRENT EVALUABLE PREDICATES


        F N                                               F       N 
        F N                                               F       N 
        F N                                               F       N 
        F N                                               F       N 
abolish(F,N)      Abolish the interpreted procedure named F arity N.
abort             Abort execution of the current directive.
          L                                                  L 
          L                                                  L 
          L                                                  L 
          L                                                  L 
ancestors(L)      The ancestor list of the current clause is L.
    N T A             N                    T    A 
    N T A             N                    T    A 
    N T A             N                    T    A 
    N T A             N                    T    A 
arg(N,T,A)        The Nth argument of term T is A.
       C                        C 
       C                        C 
       C                        C 
       C                        C 
assert(C)         Assert clause C.
                                C            R 
                                C            R 
                                C            R 
                                C            R 
assert(           Assert clause C, reference R.
        C                C                 
        C                C                 
        C                C                 
        C                C                 
asserta(C)        Assert C as first clause.
        C R              C                            R 
        C R              C                            R 
        C R              C                            R 
        C R              C                            R 
asserta(C,R)      Assert C as first clause, reference R.
        C                C                
        C                C                
        C                C                
        C                C                
assertz(C)        Assert C as last clause.
        C R              C                           R 
        C R              C                           R 
        C R              C                           R 
        C R              C                           R 
assertz(C,R)      Assert C as last clause, reference R.
     T                 T            
     T                 T            
     T                 T            
     T                 T            
atom(T)           Term T is an atom.
       T               T                       
       T               T                       
       T               T                       
       T               T                       
atomic(T)         Term T is an atom or integer.
      X P B                               X           P                B 
      X P B                               X           P                B 
      X P B                               X           P                B 
      X P B                               X           P                B 
bagof(X,P,B)      The bag of instances of X such that P is provable is B.
break             Break at the next interpreted procedure call.
     P                                                   P 
     P                                                   P 
     P                                                   P 
     P                                                   P 
call(P)           Execute the interpreted procedure call P.
       P Q                                             P       Q 
       P Q                                             P       Q 
       P Q                                             P       Q 
       P Q                                             P       Q 
clause(P,Q)       There is an interpreted clause, head P, body Q.
       P Q R                                           P       Q      R 
       P Q R                                           P       Q      R 
       P Q R                                           P       Q      R 
       P Q R                                           P       Q      R 
clause(P,Q,R)     There is an interpreted clause, head P, body Q, ref R.
      F                      F 
      F                      F 
      F                      F 
      F                      F 
close(F)          Close file F.
        C X Y     C                                  X     Y 
        C X Y     C                                  X     Y 
        C X Y     C                                  X     Y 
        C X Y     C                                  X     Y 
compare(C,X,Y)    C is the result of comparing terms X and Y.
        F                                             F 
        F                                             F 
        F                                             F 
        F                                             F 
compile(F)        Compile the procedures in text file F.
        F                                                               F 
        F                                                               F 
        F                                                               F 
        F                                                               F 
consult(F)        Extend the interpreted program with clauses from file F.
core←image        Set up a core image ready to be saved.
             A                                          A 
             A                                          A 
             A                                          A 
             A                                          A 
current←atom(A)   One of the currently defined atoms is A.
                A T                             A            T 
                A T                             A            T 
                A T                             A            T 
                A T                             A            T 
current←functor(A,T) A current functor is named A, m.g. term T.
                  A P                               A            P 
                  A P                               A            P 
                  A P                               A            P 
                  A P                               A            P 
current←predicate(A,P) A current predicate is named A, m.g. goal P.
           P T A       A                     T            P 
           P T A       A                     T            P 
           P T A       A                     T            P 
           P T A       A                     T            P 
current←op(P,T,A) Atom A is an operator type T precedence P.
debug             Switch on debugging.
debugging         Output debugging status information.
      D                                           D 
      D                                           D 
      D                                           D 
      D                                           D 
depth(D)          The current invocation depth is D.
        T                      T                 
        T                      T                 
        T                      T                 
        T                      T                 
display(T)        Display term T on the terminal.
      R                                                 R 
      R                                                 R 
      R                                                 R 
      R                                                 R 
erase(R)          Erase the clause or record, reference R.
            T X        T                                      X 
            T X        T                                      X 
            T X        T                                      X 
            T X        T                                      X 
expand←term(T,X)  Term T is a shorthand which expands to term X.
fail              Backtrack immediately.
fileerrors        Enable reporting of file errors.
        T F N                                   T          F        N 
        T F N                                   T          F        N 
        T F N                                   T          F        N 
        T F N                                   T          F        N 
functor(T,F,N)    The principal functor of term T has name F, arity N.
gc                Enable garbage collection.
        N                                       N       
        N                                       N       
        N                                       N       
        N                                       N       
gcguide(N)        The desirable GC threshold is N pages.
    C                                                   C 
    C                                                   C 
    C                                                   C 
    C                                                   C 
get(C)            The next non-blank character input is C.
     C                                        C 
     C                                        C 
     C                                        C 
     C                                        C 
get0(C)           The next character input is C.
halt              Halt Prolog, exit to the monitor.
       P                                              P 
       P                                              P 
       P                                              P 
       P                                              P 
incore(P)         Execute the compiled procedure call P.
         R T                                              R    T 
         R T                                              R    T 
         R T                                              R    T 
         R T                                              R    T 
instance(R,T)     A m.g. instance of the record reference R is T.
        T              T               
        T              T               
        T              T               
        T              T               
integer(T)        Term T is an integer.
                                      15

Y    X            Y                                    X 
Y    X            Y                                    X 
Y    X            Y                                    X 
Y    X            Y                                    X 
Y is X            Y is the value of integer expression X.
        L S                L                      S 
        L S                L                      S 
        L S                L                      S 
        L S                L                      S 
keysort(L,S)      The list L sorted by key yields S.
      M                                M 
      M                                M 
      M                                M 
      M                                M 
leash(M)          Set leashing mode to M.
       L N                           L    N 
       L N                           L    N 
       L N                           L    N 
       L N                           L    N 
length(L,N)       The length of list L is N.
listing           List the current interpreted program.
        P                                                        P 
        P                                                        P 
        P                                                        P 
        P                                                        P 
listing(P)        List the interpreted procedure(s) specified by P.
log               Enable logging.
         D                                  D 
         D                                  D 
         D                                  D 
         D                                  D 
maxdepth(D)       Limit invocation depth to D.
     A L                                      A           L 
     A L                                      A           L 
     A L                                      A           L 
     A L                                      A           L 
name(A,L)         The name of atom or integer A is string L.
nl                Output a new line.
nodebug           Switch off debugging.
nofileerrors      Disable reporting of file errors.
nogc              Disable garbage collection.
nolog             Disable logging.
       T               T                   
       T               T                   
       T               T                   
       T               T                   
nonvar(T)         Term T is a non-variable.
      P                                                                P 
      P                                                                P 
      P                                                                P 
      P                                                                P 
nospy P           Remove spy-points from the procedure(s) specified by P.
           T M N                               T      M    N   
           T M N                               T      M    N   
           T M N                               T      M    N   
           T M N                               T      M    N   
numbervars(T,M,N) Number the variables in term T from M to N-1.
   P T A                    A                     T            P 
   P T A                    A                     T            P 
   P T A                    A                     T            P 
   P T A                    A                     T            P 
op(P,T,A)         Make atom A an operator of type T precedence P.
       P L             L                                   P 
       P L             L                                   P 
       P L             L                                   P 
       P L             L                                   P 
phrase(P,L)       List L can be parsed as a phrase of type P.
        T                      T                                          
        T                      T                                          
        T                      T                                          
        T                      T                                          
portray(T)        Portray term T according to the user supplied procedure.
      T                                          T 
      T                                          T 
      T                                          T 
      T                                          T 
print(T)          Portray or else write the term T.
       A B                               A    B 
       A B                               A    B 
       A B                               A    B 
       A B                               A    B 
prompt(A,B)       Change the prompt from A to B.
    C                                          C 
    C                                          C 
    C                                          C 
    C                                          C 
put(C)            The next character output is C.
     T                      T 
     T                      T 
     T                      T 
     T                      T 
read(T)           Read term T.
          F                                                                F 
          F                                                                F 
          F                                                                F 
          F                                                                F 
reconsult(F)      Update the interpreted program with procedures from file F.
        K T R               T                            K            R 
        K T R               T                            K            R 
        K T R               T                            K            R 
        K T R               T                            K            R 
recorda(K,T,R)    Make term T the first record under key K, reference R.
         K T R         T                       K            R 
         K T R         T                       K            R 
         K T R         T                       K            R 
         K T R         T                       K            R 
recorded(K,T,R)   Term T is recorded under key K, reference R.
        K T R               T                           K            R 
        K T R               T                           K            R 
        K T R               T                           K            R 
        K T R               T                           K            R 
recordz(K,T,R)    Make term T the last record under key K, reference R.
       F G                    F    G 
       F G                    F    G 
       F G                    F    G 
       F G                    F    G 
rename(F,G)       Rename file F to G.
repeat            Succeed repeatedly.
        S                                         S 
        S                                         S 
        S                                         S 
        S                                         S 
restore(S)        Restore the state saved in file S.
        C                                                    C 
        C                                                    C 
        C                                                    C 
        C                                                    C 
retract(C)        Erase the first interpreted clause of form C.
       F N                                                   F       N 
       F N                                                   F       N 
       F N                                                   F       N 
       F N                                                   F       N 
revive(F,N)       Revive the latest compiled procedure named F arity N.
     S                                                     S 
     S                                                     S 
     S                                                     S 
     S                                                     S 
save(S)           Save the current state of Prolog in file S.
    F                       F                          
    F                       F                          
    F                       F                          
    F                       F                          
see(F)            Make file F the current input stream.
       F                                            F 
       F                                            F 
       F                                            F 
       F                                            F 
seeing(F)         The current input stream is named F.
seen              Close the current input stream.
      X P S                               X           P                S 
      X P S                               X           P                S 
      X P S                               X           P                S 
      X P S                               X           P                S 
setof(X,P,S)      The set of instances of X such that P is provable is S.
     C                                                        C 
     C                                                        C 
     C                                                        C 
     C                                                        C 
skip(C)           Skip input characters until after character C.
     L S                   L                          S 
     L S                   L                          S 
     L S                   L                          S 
     L S                   L                          S 
sort(L,S)         The list L sorted into order yields S.
    P                                                             P 
    P                                                             P 
    P                                                             P 
    P                                                             P 
spy P             Set spy-points on the procedure(s) specified by P.
statistics        Output various execution statistics.
           K V                                K           V 
           K V                                K           V 
           K V                                K           V 
           K V                                K           V 
statistics(K,V)   The execution statistic key K has value V.
           G                                                G 
           G                                                G 
           G                                                G 
           G                                                G 
subgoal←of(G)     An ancestor goal of the current clause is G.
    N                    N        
    N                    N        
    N                    N        
    N                    N        
tab(N)            Output N spaces.
     F                      F                           
     F                      F                           
     F                      F                           
     F                      F                           
tell(F)           Make file F the current output stream.
        F                                            F 
        F                                            F 
        F                                            F 
        F                                            F 
telling(F)        The current output stream is named F.
told              Close the current output stream.
trace             Switch on debugging and start tracing immediately.
trimcore          Reduce free stack space to a minimum.
true              Succeed.
ttyflush          Transmit all outstanding terminal output.
                                      16

       C                                                                  C 
       C                                                                  C 
       C                                                                  C 
       C                                                                  C 
ttyget(C)         The next non-blank character input from the terminal is C.
        C                                                       C 
        C                                                       C 
        C                                                       C 
        C                                                       C 
ttyget0(C)        The next character input from the terminal is C.
ttynl             Output a new line on the terminal.
       C                                                       C 
       C                                                       C 
       C                                                       C 
       C                                                       C 
ttyput(C)         The next character output to the terminal is C.
        C                                                        C 
        C                                                        C 
        C                                                        C 
        C                                                        C 
ttyskip(C)        Skip over terminal input until after character C.
       N                 N                        
       N                 N                        
       N                 N                        
       N                 N                        
ttytab(N)         Output N spaces to the terminal.
    T                  T               
    T                  T               
    T                  T               
    T                  T               
var(T)            Term T is a variable.
      T                          T 
      T                          T 
      T                          T 
      T                          T 
write(T)          Write the term T.
       T                         T                                
       T                         T                                
       T                         T                                
       T                         T                                
writeq(T)         Write the term T, quoting names where necessary.

'LC'              The following Prolog text uses lower case.
'NOLC'            The following Prolog text uses upper case only.

!                 Cut any choices taken in the current procedure.
   P                   P                 
   P                   P                 
   P                   P                 
   P                   P                 
\+ P              Goal P is not provable.
X P                               X           P             
X P                               X           P             
X P                               X           P             
X P                               X           P             
X↑P               There exists an X such that P is provable.
X Y                                  X              Y 
X Y                                  X              Y 
X Y                                  X              Y 
X Y                                  X              Y 
X<Y               As integer values, X is less than Y.
X  Y                                 X                          Y 
X  Y                                 X                          Y 
X  Y                                 X                          Y 
X  Y                                 X                          Y 
X=<Y              As integer values, X is less than or equal to Y.
X Y                                  X                 Y 
X Y                                  X                 Y 
X Y                                  X                 Y 
X Y                                  X                 Y 
X>Y               As integer values, X is greater than Y.
X  Y                                 X                             Y 
X  Y                                 X                             Y 
X  Y                                 X                             Y 
X  Y                                 X                             Y 
X>=Y              As integer values, X is greater than or equal to Y.
X Y                     X     Y                         
X Y                     X     Y                         
X Y                     X     Y                         
X Y                     X     Y                         
X=Y               Terms X and Y are equal (ie. unified).
T   L                                               T                   L 
T   L                                               T                   L 
T   L                                               T                   L 
T   L                                               T                   L 
T=..L             The functor and arguments of term T comprise the list L.
X  Y                    X     Y                        
X  Y                    X     Y                        
X  Y                    X     Y                        
X  Y                    X     Y                        
X==Y              Terms X and Y are strictly identical.
X   Y                   X     Y                            
X   Y                   X     Y                            
X   Y                   X     Y                            
X   Y                   X     Y                            
X\==Y             Terms X and Y are not strictly identical.
X  Y                   X               Y 
X  Y                   X               Y 
X  Y                   X               Y 
X  Y                   X               Y 
X@<Y              Term X precedes term Y.
X   Y                  X                                  Y 
X   Y                  X                                  Y 
X   Y                  X                                  Y 
X   Y                  X                                  Y 
X@=<Y             Term X precedes or is identical to term Y.
X  Y                   X              Y 
X  Y                   X              Y 
X  Y                   X              Y 
X  Y                   X              Y 
X@>Y              Term X follows term Y.
X   Y                  X                                 Y 
X   Y                  X                                 Y 
X   Y                  X                                 Y 
X   Y                  X                                 Y 
X@>=Y             Term X follows or is identical to term Y.

 F R                                                       F R  
 F R                                                       F R  
 F R                                                       F R  
 F R                                                       F R  
[F|R]             Perform the (re)consult(s) specified by [F|R].



                              Table of Contents
                              Table of Contents
                              Table of Contents
                              Table of Contents
                              Table of Contents

1. SUMMARY                                                                   1
2. INCOMPATIBLE CHANGES                                                      1
3. THE INCORE COMPILER                                                       2
     3.1. Calling the Compiler                                               2
     3.2. Public Declarations                                                2
     3.3. Mode Declarations                                                  3
     3.4. Indexing                                                           3
     3.5. Tail Recursion Optimisation                                        4
     3.6. Practical Limitations                                              4
4. PROGRAM DEVELOPMENT AIDS                                                  4
5. OTHER NEW FEATURES                                                        5
     5.1. Initialisation File                                                5
     5.2. Terminal prompts                                                   5
     5.3. End of Line Comments                                               5
     5.4. Handling of Line Terminators                                       5
     5.5. End of File Marker                                                 5
6. NEW OPERATORS                                                             6
7. NEW EVALUABLE PREDICATES                                                  6
     7.1. Compiled Program                                                   6
     7.2. Interpreted Program etc.                                           7
     7.3. Internal Database                                                  8
     7.4. Meta-Logical                                                       8
     7.5. Comparison of Terms                                               10
     7.6. Input-Output                                                      11
     7.7. Environmental                                                     12
     7.8. Debugging                                                         12
     7.9. Pre-Processing                                                    13
     7.10. Grammars                                                         13
8. GLOSSARY OF CURRENT EVALUABLE PREDICATES                                 14